function varargout = Acq_params(varargin)

% $Id: Acq_params.m 329 2005-05-09 20:31:24Z odellj $
% ACQ_PARAMS Application M-file for Acq_params.fig
%    FIG = ACQ_PARAMS launch Acq_params GUI.
%    ACQ_PARAMS('callback_name', ...) invoke the named callback.

% Last Modified by GUIDE v2.5 13-Oct-2011 12:12:26
% $Log: Acq_params.m,v $
% Revision 1.3  2004/09/09 21:05:01  odellj
% Fixed ndets to n_dets.
%
% Revision 1.2  2004/03/29 20:55:21  odellj
% Added nonzero warning for the sample rate.
%
% Revision 1.1.1.1  2004/02/18 20:09:49  odellj
% initial import into CVS
%
% Revision 1.2  2004/02/05 18:26:38  odellj
% Added Id and Log tags.
%

global hdr fig

if nargin == 0  % LAUNCH GUI

	fig = openfig(mfilename,'reuse');

	% Use system color scheme for figure:
	set(fig,'Color',get(0,'defaultUicontrolBackgroundColor'));

	% Generate a structure of handles to pass to callbacks, and store it. 
	handles = guihandles(fig);
    
    set(handles.n_srcs_str,'String',num2str(hdr.n_srcs));
    set(handles.n_dets_str,'String',num2str(hdr.n_dets));
    set(handles.n_points_str,'String',num2str(hdr.n_points));
    set(handles.edit4,'String',num2str(hdr.sample_rate));
%     set(handles.n_trials_str,'String',num2str(hdr.n_trials));
    set(handles.n_blocks_str,'String',num2str(hdr.n_blocks));

	guidata(fig, handles);

	if nargout > 0
		varargout{1} = fig;
	end

elseif ischar(varargin{1}) % INVOKE NAMED SUBFUNCTION OR CALLBACK

	try
		if (nargout)
			[varargout{1:nargout}] = feval(varargin{:}); % FEVAL switchyard
		else
			feval(varargin{:}); % FEVAL switchyard
		end
	catch
		disp(lasterr);
	end

end

% --------------------------------------------------------------------
function varargout = n_srcs_str_Callback(h, eventdata, handles, varargin)

global hdr
Value=get(h,'String');
set(handles.n_srcs_str,'String',Value);
guidata(h,handles);
hdr.n_srcs=str2num(Value);
hdr.n_chans=hdr.n_srcs*hdr.n_dets;

% --------------------------------------------------------------------
function varargout = n_dets_str_Callback(h, eventdata, handles, varargin)

global hdr
Value=get(h,'String');
set(handles.n_dets_str,'String',Value);
guidata(h,handles);
hdr.n_dets=str2num(Value);
hdr.n_chans=hdr.n_srcs*hdr.n_dets;

% --------------------------------------------------------------------
function varargout = n_points_str_Callback(h, eventdata, handles, varargin)

global hdr
Value=get(h,'String');
set(handles.n_points_str,'String',Value);
guidata(h,handles);
hdr.n_points=str2num(Value);

% --------------------------------------------------------------------
function varargout = edit4_Callback(h, eventdata, handles, varargin)

global hdr
Value=get(h,'String');
set(handles.edit4,'String',Value);
guidata(h,handles);
hdr.sample_rate=str2num(Value);
if hdr.sample_rate == 0
    msg=sprintf('Warning:  Sample rate should be nonzero.');
end
hdr.period=1/hdr.sample_rate;
hdr.period_ms=1000*hdr.period;

% --------------------------------------------------------------------
function varargout = n_trials_str_Callback(h, eventdata, handles, varargin)

global hdr
Value=get(h,'String');
set(handles.n_trials_str,'String',Value);
guidata(h,handles);
hdr.n_trials=str2num(Value);

% --------------------------------------------------------------------
function varargout = n_blocks_str_Callback(h, eventdata, handles, varargin)

global hdr
disp('Acq_params 118')
Value=get(h,'String');
set(handles.n_blocks_str,'String',Value);
guidata(h,handles);
hdr.n_blocks=str2num(Value);

% --------------------------------------------------------------------
function varargout = Done_Callback(h, eventdata, handles, varargin)
disp('Acq_params 125')
close



% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over Done.
function Done_ButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to Done (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
